package com.song.sparkstudy;

import org.apache.spark.SparkConf;
import org.apache.spark.SparkContext;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.broadcast.Broadcast;

/**
 *  广播变量  所有的节点都能接受到这个变量
 * @author root
 *
 */
public class JavaBroadcaseTest {
	
	public static void main(String[] args) {
		SparkConf conf = new SparkConf().setAppName("broadcasetest");
		JavaSparkContext context = new JavaSparkContext(conf);
		
		Broadcast<int[]> broadcastvar = context.broadcast(new int[]{2,2,5,7});
		
		for(int val :broadcastvar.value())
		{
			System.out.println("  "+val);
		}
		
		context.close();
	}

}
